Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 1x 1x 2x 2x 2x 1x 2x 2x 2x 3x 1x 2x | import Link from 'next/link';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { Breadcrumbs } from '@/components/Breadcrumbs';
import { DocShell } from '@/components/DocShell';
import { getCategoryBySlug, getNavigation } from '@/lib/navigation';
export const dynamicParams = false;
type RouteParams = { category: string };
export function generateStaticParams(): RouteParams[] {
return getNavigation().map((c) => ({ category: c.slug }));
}
export async function generateMetadata({ params }: { params: Promise<RouteParams> }): Promise<Metadata> {
const { category } = await params;
const found = getCategoryBySlug(category);
if (!found) return {};
return { title: `${found.name} | SLDS 2` };
}
export default async function CategoryIndexPage({ params }: { params: Promise<RouteParams> }) {
const { category } = await params;
const found = getCategoryBySlug(category);
if (!found) notFound();
const pages = found.children.filter((p) => !p.hidden);
return (
<DocShell>
<Breadcrumbs items={[{ name: found.name, url: `/${found.slug}` }]} />
<h1>{found.name}</h1>
<ul className="category-index">
{pages.map((p) => (
<li key={p.id} className="category-index__item">
<Link href={p.url} className="category-index__link">
<span className="category-index__title">{p.name}</span>
</Link>
</li>
))}
</ul>
</DocShell>
);
}
|